package com.wanhe.shoppingcart.counter;

import com.wanhe.base.model.base.Dish;
import com.wanhe.base.model.holder.DishHolder;
import com.wanhe.base.util.ObjectUtil;
import com.wanhe.shoppingcart.manager.ICartItem;

/**
 * Created by XieZaiWei on 2017/5/9.
 * 显示二级菜单，在二级菜单中进行菜品的添加和删除操作
 */

public class ShowSecLevelDialogCounter extends BaseCustomCounter implements ICounter {
	public static final String COUNTER_TYPE = "show_dialog";

	public ShowSecLevelDialogCounter(BaseCounter counter) {
		super(counter);
	}

	@Override
	public String getCounterType() {
		return COUNTER_TYPE;
	}

	@Override
	public void plus(String foodID, boolean isNeedSyncToServer) {
		Dish food = DishHolder.getInstance().get(foodID);
		if (ObjectUtil.checkObject(food)) {
			mBaseCounter.plus(foodID, isNeedSyncToServer);
		}
	}

	@Override
	public void plus(ICartItem item, boolean isNeedSyncToServer) {
		this.mBaseCounter.plus(item, isNeedSyncToServer);
	}

	@Override
	public void reduce(String foodID, boolean isNeedSyncToServer) {
		Dish food = DishHolder.getInstance().get(foodID);
		if (ObjectUtil.checkObject(food)) {
			mBaseCounter.reduce(foodID, isNeedSyncToServer);
		}
	}

	@Override
	public void reduce(ICartItem item, boolean isNeedSyncToServer) {
		this.mBaseCounter.reduce(item, isNeedSyncToServer);
	}

	@Override
	public boolean isCountFilled() {
		return true;
	}
}
